// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.network;

import java.util.ArrayList;
import org.lwjgl.opengl.GL11;
import org.lwjglx.opengl.Display;
import org.lwjglx.opengl.DisplayMode;
import org.lwjglx.opengl.PixelFormat;
import zombie.Lua.LuaEventManager;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.characters.IsoZombie;
import zombie.core.Core;
import zombie.core.PerformanceSettings;
import zombie.core.SpriteRenderer;
import zombie.core.VBO.GLVertexBufferObject;
import zombie.core.opengl.RenderThread;
import zombie.core.physics.WorldSimulation;
import zombie.core.properties.PropertyContainer;
import zombie.core.raknet.UdpConnection;
import zombie.core.textures.ColorInfo;
import zombie.core.textures.TextureDraw;
import zombie.core.textures.TexturePackPage;
import zombie.debug.LineDrawer;
import zombie.gameStates.MainScreenState;
import zombie.input.GameKeyboard;
import zombie.input.Mouse;
import zombie.iso.IsoCamera;
import zombie.iso.IsoCell;
import zombie.iso.IsoChunk;
import zombie.iso.IsoDirections;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoMovingObject;
import zombie.iso.IsoObject;
import zombie.iso.IsoObjectPicker;
import zombie.iso.IsoUtils;
import zombie.iso.IsoWorld;
import zombie.iso.PlayerCamera;
import zombie.iso.SpriteDetails.IsoFlagType;
import zombie.iso.SpriteDetails.IsoObjectType;
import zombie.iso.areas.IsoRoom;
import zombie.iso.objects.IsoBarricade;
import zombie.iso.objects.IsoCurtain;
import zombie.iso.objects.IsoDeadBody;
import zombie.iso.objects.IsoTree;
import zombie.iso.objects.IsoWindow;
import zombie.iso.sprite.IsoSprite;
import zombie.ui.TextManager;
import zombie.vehicles.BaseVehicle;

public class ServerGUI {
    private static boolean created;
    private static int minX;
    private static int minY;
    private static int maxX;
    private static int maxY;
    private static int maxZ;
    private static final ArrayList<IsoGridSquare> GridStack = new ArrayList();
    private static final ArrayList<IsoGridSquare> MinusFloorCharacters = new ArrayList(1000);
    private static final ArrayList<IsoGridSquare> SolidFloor = new ArrayList(5000);
    private static final ArrayList<IsoGridSquare> VegetationCorpses = new ArrayList(5000);
    private static final ColorInfo defColorInfo = new ColorInfo();

    public static boolean isCreated() {
        return created;
    }

    public static void init() {
        created = true;

        try {
            Display.setFullscreen(false);
            Display.setResizable(false);
            Display.setVSyncEnabled(false);
            Display.setTitle("Project Zomboid Server");
            System.setProperty("org.lwjgl.opengl.Window.undecorated", "false");
            Core.width = 1366;
            Core.height = 768;
            Display.setDisplayMode(new DisplayMode(Core.width, Core.height));
            Display.create(new PixelFormat(32, 0, 24, 8, 0));
            Display.setIcon(MainScreenState.loadIcons());
            GLVertexBufferObject.init();
            Display.makeCurrent();
            SpriteRenderer.instance.create();
            TextManager.instance.Init();

            while (TextManager.instance.font.isEmpty()) {
                zombie.GameWindow.fileSystem.updateAsyncTransactions();

                try {
                    Thread.sleep(10L);
                } catch (InterruptedException interruptedException) {
                }
            }

            TexturePackPage.bIgnoreWorldItemTextures = true;
            byte _byte = 2;
            zombie.GameWindow.LoadTexturePack("UI", _byte);
            zombie.GameWindow.LoadTexturePack("UI2", _byte);
            zombie.GameWindow.LoadTexturePack("IconsMoveables", _byte);
            zombie.GameWindow.LoadTexturePack("RadioIcons", _byte);
            zombie.GameWindow.LoadTexturePack("ApComUI", _byte);
            zombie.GameWindow.LoadTexturePack("WeatherFx", _byte);
            TexturePackPage.bIgnoreWorldItemTextures = false;
            _byte = 0;
            zombie.GameWindow.LoadTexturePack("Tiles2x", _byte);
            zombie.GameWindow.LoadTexturePack("JumboTrees2x", _byte);
            zombie.GameWindow.LoadTexturePack("Overlays2x", _byte);
            zombie.GameWindow.LoadTexturePack("Tiles2x.floor", 0);
            zombie.GameWindow.DoLoadingText("");
            zombie.GameWindow.setTexturePackLookup();
            IsoObjectPicker.Instance.Init();
            Display.makeCurrent();
            GL11.glClearColor(0.0F, 0.0F, 0.0F, 1.0F);
            Display.releaseContext();
            RenderThread.initServerGUI();
            RenderThread.startRendering();
            Core.getInstance().initFBOs();
        } catch (Exception exception) {
            exception.printStackTrace();
            created = false;
        }
    }

    public static void init2() {
        if (created) {
            BaseVehicle.LoadAllVehicleTextures();
        }
    }

    public static void shutdown() {
        if (created) {
            RenderThread.shutdown();
        }
    }

    public static void update() {
        if (created) {
            Mouse.update();
            GameKeyboard.update();
            Display.processMessages();
            if (RenderThread.isCloseRequested()) {
            }

            int int0 = Mouse.getWheelState();
            if (int0 != 0) {
                int int1 = int0 - 0 < 0 ? 1 : -1;
                Core.getInstance().doZoomScroll(0, int1);
            }

            byte _byte = 0;
            IsoPlayer isoPlayer = getPlayerToFollow();
            if (isoPlayer == null) {
                Core.getInstance().StartFrame();
                Core.getInstance().EndFrame();
                Core.getInstance().StartFrameUI();
                SpriteRenderer.instance
                    .renderi(null, 0, 0, Core.getInstance().getScreenWidth(), Core.getInstance().getScreenHeight(), 0.0F, 0.0F, 0.0F, 1.0F, null);
                Core.getInstance().EndFrameUI();
            } else {
                IsoPlayer.setInstance(isoPlayer);
                IsoPlayer.players[_byte] = isoPlayer;
                IsoCamera.CamCharacter = isoPlayer;
                Core.getInstance().StartFrame(_byte, true);
                renderWorld();
                Core.getInstance().EndFrame(_byte);
                Core.getInstance().RenderOffScreenBuffer();
                Core.getInstance().StartFrameUI();
                renderUI();
                Core.getInstance().EndFrameUI();
            }
        }
    }

    private static IsoPlayer getPlayerToFollow() {
        for (int int0 = 0; int0 < GameServer.udpEngine.connections.size(); int0++) {
            UdpConnection udpConnection = (UdpConnection)GameServer.udpEngine.connections.get(int0);
            if (udpConnection.isFullyConnected()) {
                for (int int1 = 0; int1 < 4; int1++) {
                    IsoPlayer isoPlayer = udpConnection.players[int1];
                    if (isoPlayer != null && isoPlayer.OnlineID != -1) {
                        return isoPlayer;
                    }
                }
            }
        }

        return null;
    }

    private static void updateCamera(IsoPlayer isoPlayer) {
        byte _byte = 0;
        PlayerCamera playerCamera = IsoCamera.cameras[_byte];
        float float0 = IsoUtils.XToScreen(isoPlayer.x + playerCamera.DeferedX, isoPlayer.y + playerCamera.DeferedY, isoPlayer.z, 0);
        float float1 = IsoUtils.YToScreen(isoPlayer.x + playerCamera.DeferedX, isoPlayer.y + playerCamera.DeferedY, isoPlayer.z, 0);
        float0 -= (float)(IsoCamera.getOffscreenWidth(_byte) / 2);
        float1 -= (float)(IsoCamera.getOffscreenHeight(_byte) / 2);
        float1 -= isoPlayer.getOffsetY() * 1.5F;
        float0 += (float)IsoCamera.PLAYER_OFFSET_X;
        float1 += (float)IsoCamera.PLAYER_OFFSET_Y;
        playerCamera.OffX = float0;
        playerCamera.OffY = float1;
        IsoCamera.FrameState frameState = IsoCamera.frameState;
        frameState.Paused = false;
        frameState.playerIndex = _byte;
        frameState.CamCharacter = isoPlayer;
        frameState.CamCharacterX = IsoCamera.CamCharacter.getX();
        frameState.CamCharacterY = IsoCamera.CamCharacter.getY();
        frameState.CamCharacterZ = IsoCamera.CamCharacter.getZ();
        frameState.CamCharacterSquare = IsoCamera.CamCharacter.getCurrentSquare();
        frameState.CamCharacterRoom = frameState.CamCharacterSquare == null ? null : frameState.CamCharacterSquare.getRoom();
        frameState.OffX = IsoCamera.getOffX();
        frameState.OffY = IsoCamera.getOffY();
        frameState.OffscreenWidth = IsoCamera.getOffscreenWidth(_byte);
        frameState.OffscreenHeight = IsoCamera.getOffscreenHeight(_byte);
    }

    private static void renderWorld() {
        IsoPlayer isoPlayer = getPlayerToFollow();
        if (isoPlayer != null) {
            byte byte0 = 0;
            IsoPlayer.setInstance(isoPlayer);
            IsoPlayer.players[0] = isoPlayer;
            IsoCamera.CamCharacter = isoPlayer;
            updateCamera(isoPlayer);
            SpriteRenderer.instance.doCoreIntParam(0, IsoCamera.CamCharacter.x);
            SpriteRenderer.instance.doCoreIntParam(1, IsoCamera.CamCharacter.y);
            SpriteRenderer.instance.doCoreIntParam(2, IsoCamera.CamCharacter.z);
            IsoWorld.instance.sceneCullZombies();
            IsoSprite.globalOffsetX = -1.0F;
            byte byte1 = 0;
            byte byte2 = 0;
            int int0 = byte1 + IsoCamera.getOffscreenWidth(byte0);
            int int1 = byte2 + IsoCamera.getOffscreenHeight(byte0);
            float float0 = IsoUtils.XToIso((float)byte1, (float)byte2, 0.0F);
            float float1 = IsoUtils.YToIso((float)int0, (float)byte2, 0.0F);
            float float2 = IsoUtils.XToIso((float)int0, (float)int1, 6.0F);
            float float3 = IsoUtils.YToIso((float)byte1, (float)int1, 6.0F);
            minY = (int)float1;
            maxY = (int)float3;
            minX = (int)float0;
            maxX = (int)float2;
            minX -= 2;
            minY -= 2;
            maxZ = (int)isoPlayer.getZ();
            IsoCell isoCell = IsoWorld.instance.CurrentCell;
            isoCell.DrawStencilMask();
            IsoObjectPicker.Instance.StartRender();
            RenderTiles();

            for (int int2 = 0; int2 < isoCell.getObjectList().size(); int2++) {
                IsoMovingObject isoMovingObject = (IsoMovingObject)isoCell.getObjectList().get(int2);
                isoMovingObject.renderlast();
            }

            for (int int3 = 0; int3 < isoCell.getStaticUpdaterObjectList().size(); int3++) {
                IsoObject isoObject = (IsoObject)isoCell.getStaticUpdaterObjectList().get(int3);
                isoObject.renderlast();
            }

            if (WorldSimulation.instance.created) {
                TextureDraw.GenericDrawer genericDrawer = WorldSimulation.getDrawer(byte0);
                SpriteRenderer.instance.drawGeneric(genericDrawer);
            }

            zombie.WorldSoundManager.instance.render();
            LineDrawer.clear();
        }
    }

    private static void RenderTiles() {
        IsoCell isoCell = IsoWorld.instance.CurrentCell;
        if (IsoCell.perPlayerRender[0] == null) {
            IsoCell.perPlayerRender[0] = new IsoCell.PerPlayerRender();
        }

        IsoCell.PerPlayerRender perPlayerRender = IsoCell.perPlayerRender[0];
        if (perPlayerRender == null) {
            IsoCell.perPlayerRender[0] = new IsoCell.PerPlayerRender();
        }

        perPlayerRender.setSize(maxX - minX + 1, maxY - minY + 1);
        short[][][] _short = perPlayerRender.StencilValues;

        for (int int0 = 0; int0 <= maxZ; int0++) {
            GridStack.clear();

            for (int int1 = minY; int1 < maxY; int1++) {
                int int2 = minX;
                IsoGridSquare isoGridSquare0 = ServerMap.instance.getGridSquare(int2, int1, int0);
                int int3 = IsoDirections.E.index();

                while (int2 < maxX) {
                    if (int0 == 0) {
                        _short[int2 - minX][int1 - minY][0] = 0;
                        _short[int2 - minX][int1 - minY][1] = 0;
                    }

                    if (isoGridSquare0 != null && isoGridSquare0.getY() != int1) {
                        isoGridSquare0 = null;
                    }

                    if (isoGridSquare0 == null) {
                        isoGridSquare0 = ServerMap.instance.getGridSquare(int2, int1, int0);
                        if (isoGridSquare0 == null) {
                            int2++;
                            continue;
                        }
                    }

                    IsoChunk isoChunk = isoGridSquare0.getChunk();
                    if (isoChunk != null && isoGridSquare0.IsOnScreen()) {
                        GridStack.add(isoGridSquare0);
                    }

                    isoGridSquare0 = isoGridSquare0.nav[int3];
                    int2++;
                }
            }

            SolidFloor.clear();
            VegetationCorpses.clear();
            MinusFloorCharacters.clear();

            for (int int4 = 0; int4 < GridStack.size(); int4++) {
                IsoGridSquare isoGridSquare1 = (IsoGridSquare)GridStack.get(int4);
                isoGridSquare1.setLightInfoServerGUIOnly(defColorInfo);
                int int5 = renderFloor(isoGridSquare1);
                if (!isoGridSquare1.getStaticMovingObjects().isEmpty()) {
                    int5 |= 2;
                }

                for (int int6 = 0; int6 < isoGridSquare1.getMovingObjects().size(); int6++) {
                    IsoMovingObject isoMovingObject = (IsoMovingObject)isoGridSquare1.getMovingObjects().get(int6);
                    boolean boolean0 = isoMovingObject.isOnFloor();
                    if (boolean0 && isoMovingObject instanceof IsoZombie isoZombie) {
                        boolean0 = isoZombie.bCrawling
                            || isoZombie.legsSprite.CurrentAnim != null
                                && isoZombie.legsSprite.CurrentAnim.name.equals("ZombieDeath")
                                && isoZombie.def.isFinished();
                    }

                    if (boolean0) {
                        int5 |= 2;
                    } else {
                        int5 |= 4;
                    }
                }

                if ((int5 & 1) != 0) {
                    SolidFloor.add(isoGridSquare1);
                }

                if ((int5 & 2) != 0) {
                    VegetationCorpses.add(isoGridSquare1);
                }

                if ((int5 & 4) != 0) {
                    MinusFloorCharacters.add(isoGridSquare1);
                }
            }

            LuaEventManager.triggerEvent("OnPostFloorLayerDraw", int0);

            for (int int7 = 0; int7 < VegetationCorpses.size(); int7++) {
                IsoGridSquare isoGridSquare2 = (IsoGridSquare)VegetationCorpses.get(int7);
                renderMinusFloor(isoGridSquare2, false, true);
                renderCharacters(isoGridSquare2, true);
            }

            for (int int8 = 0; int8 < MinusFloorCharacters.size(); int8++) {
                IsoGridSquare isoGridSquare3 = (IsoGridSquare)MinusFloorCharacters.get(int8);
                boolean boolean1 = renderMinusFloor(isoGridSquare3, false, false);
                renderCharacters(isoGridSquare3, false);
                if (boolean1) {
                    renderMinusFloor(isoGridSquare3, true, false);
                }
            }
        }

        MinusFloorCharacters.clear();
        SolidFloor.clear();
        VegetationCorpses.clear();
    }

    private static int renderFloor(IsoGridSquare isoGridSquare) {
        byte byte0 = 0;
        byte byte1 = 0;

        for (int _int = 0; _int < isoGridSquare.getObjects().size(); _int++) {
            IsoObject isoObject = isoGridSquare.getObjects().get(_int);
            boolean _boolean = true;
            if (isoObject.sprite != null && !isoObject.sprite.Properties.Is(IsoFlagType.solidfloor)) {
                _boolean = false;
                byte0 |= 4;
            }

            if (_boolean) {
                zombie.IndieGL.glAlphaFunc(516, 0.0F);
                isoObject.setAlphaAndTarget(byte1, 1.0F);
                isoObject.render((float)isoGridSquare.x, (float)isoGridSquare.y, (float)isoGridSquare.z, defColorInfo, true, false, null);
                isoObject.renderObjectPicker((float)isoGridSquare.x, (float)isoGridSquare.y, (float)isoGridSquare.z, defColorInfo);
                if ((isoObject.highlightFlags & 2) != 0) {
                    isoObject.highlightFlags &= -2;
                }

                byte0 |= 1;
            }

            if (!_boolean
                && isoObject.sprite != null
                && (isoObject.sprite.Properties.Is(IsoFlagType.canBeRemoved) || isoObject.sprite.Properties.Is(IsoFlagType.attachedFloor))) {
                byte0 |= 2;
            }
        }

        return byte0;
    }

    private static boolean isSpriteOnSouthOrEastWall(IsoObject isoObject) {
        if (isoObject instanceof IsoBarricade) {
            return isoObject.getDir() == IsoDirections.S || isoObject.getDir() == IsoDirections.E;
        } else if (isoObject instanceof IsoCurtain isoCurtain) {
            return isoCurtain.getType() == IsoObjectType.curtainS || isoCurtain.getType() == IsoObjectType.curtainE;
        } else {
            PropertyContainer propertyContainer = isoObject.getProperties();
            return propertyContainer != null && (propertyContainer.Is(IsoFlagType.attachedE) || propertyContainer.Is(IsoFlagType.attachedS));
        }
    }

    private static int DoWallLightingN(IsoGridSquare isoGridSquare, IsoObject isoObject, int _int) {
        isoObject.render((float)isoGridSquare.x, (float)isoGridSquare.y, (float)isoGridSquare.z, defColorInfo, true, false, null);
        return _int;
    }

    private static int DoWallLightingW(IsoGridSquare isoGridSquare, IsoObject isoObject, int _int) {
        isoObject.render((float)isoGridSquare.x, (float)isoGridSquare.y, (float)isoGridSquare.z, defColorInfo, true, false, null);
        return _int;
    }

    private static int DoWallLightingNW(IsoGridSquare isoGridSquare, IsoObject isoObject, int _int) {
        isoObject.render((float)isoGridSquare.x, (float)isoGridSquare.y, (float)isoGridSquare.z, defColorInfo, true, false, null);
        return _int;
    }

    private static boolean renderMinusFloor(IsoGridSquare isoGridSquare0, boolean boolean0, boolean boolean4) {
        int int0 = boolean0 ? isoGridSquare0.getObjects().size() - 1 : 0;
        int int1 = boolean0 ? 0 : isoGridSquare0.getObjects().size() - 1;
        int int2 = IsoCamera.frameState.playerIndex;
        IsoGridSquare isoGridSquare1 = IsoCamera.frameState.CamCharacterSquare;
        IsoRoom isoRoom = IsoCamera.frameState.CamCharacterRoom;
        int int3 = (int)(IsoUtils.XToScreenInt(isoGridSquare0.x, isoGridSquare0.y, isoGridSquare0.z, 0) - IsoCamera.frameState.OffX);
        int int4 = (int)(IsoUtils.YToScreenInt(isoGridSquare0.x, isoGridSquare0.y, isoGridSquare0.z, 0) - IsoCamera.frameState.OffY);
        boolean boolean1 = true;
        IsoCell isoCell = isoGridSquare0.getCell();
        if (int3 + 32 * Core.TileScale <= isoCell.StencilX1
            || int3 - 32 * Core.TileScale >= isoCell.StencilX2
            || int4 + 32 * Core.TileScale <= isoCell.StencilY1
            || int4 - 96 * Core.TileScale >= isoCell.StencilY2) {
            boolean1 = false;
        }

        int int5 = 0;
        boolean boolean2 = false;

        for (int int6 = int0; boolean0 ? int6 >= int1 : int6 <= int1; int6 += boolean0 ? -1 : 1) {
            IsoObject isoObject = isoGridSquare0.getObjects().get(int6);
            boolean boolean3 = true;
            IsoGridSquare.CircleStencil = false;
            if (isoObject.sprite != null && isoObject.sprite.getProperties().Is(IsoFlagType.solidfloor)) {
                boolean3 = false;
            }

            if ((
                    !boolean4
                        || isoObject.sprite == null
                        || isoObject.sprite.Properties.Is(IsoFlagType.canBeRemoved)
                        || isoObject.sprite.Properties.Is(IsoFlagType.attachedFloor)
                )
                && (
                    boolean4
                        || isoObject.sprite == null
                        || !isoObject.sprite.Properties.Is(IsoFlagType.canBeRemoved) && !isoObject.sprite.Properties.Is(IsoFlagType.attachedFloor)
                )) {
                if (isoObject.sprite != null
                    && (
                        isoObject.sprite.getType() == IsoObjectType.WestRoofB
                            || isoObject.sprite.getType() == IsoObjectType.WestRoofM
                            || isoObject.sprite.getType() == IsoObjectType.WestRoofT
                    )
                    && isoGridSquare0.z == maxZ
                    && isoGridSquare0.z == (int)IsoCamera.CamCharacter.getZ()) {
                    boolean3 = false;
                }

                if (IsoCamera.CamCharacter.isClimbing() && isoObject.sprite != null && !isoObject.sprite.getProperties().Is(IsoFlagType.solidfloor)) {
                    boolean3 = true;
                }

                if (isSpriteOnSouthOrEastWall(isoObject)) {
                    if (!boolean0) {
                        boolean3 = false;
                    }

                    boolean2 = true;
                } else if (boolean0) {
                    boolean3 = false;
                }

                if (boolean3) {
                    zombie.IndieGL.glAlphaFunc(516, 0.0F);
                    if (isoObject.sprite != null
                        && !isoGridSquare0.getProperties().Is(IsoFlagType.blueprint)
                        && (
                            isoObject.sprite.getType() == IsoObjectType.doorFrW
                                || isoObject.sprite.getType() == IsoObjectType.doorFrN
                                || isoObject.sprite.getType() == IsoObjectType.doorW
                                || isoObject.sprite.getType() == IsoObjectType.doorN
                                || isoObject.sprite.getProperties().Is(IsoFlagType.cutW)
                                || isoObject.sprite.getProperties().Is(IsoFlagType.cutN)
                        )
                        && PerformanceSettings.LightingFrameSkip < 3) {
                        if (isoObject.getTargetAlpha(int2) < 1.0F) {
                            boolean boolean5 = false;
                            if (boolean5) {
                                if (isoObject.sprite.getProperties().Is(IsoFlagType.cutW) && isoGridSquare0.getProperties().Is(IsoFlagType.WallSE)) {
                                    IsoGridSquare isoGridSquare2 = isoGridSquare0.nav[IsoDirections.NW.index()];
                                    if (isoGridSquare2 == null || isoGridSquare2.getRoom() == null) {
                                        boolean5 = false;
                                    }
                                } else if (isoObject.sprite.getType() != IsoObjectType.doorFrW
                                    && isoObject.sprite.getType() != IsoObjectType.doorW
                                    && !isoObject.sprite.getProperties().Is(IsoFlagType.cutW)) {
                                    if (isoObject.sprite.getType() == IsoObjectType.doorFrN
                                        || isoObject.sprite.getType() == IsoObjectType.doorN
                                        || isoObject.sprite.getProperties().Is(IsoFlagType.cutN)) {
                                        IsoGridSquare isoGridSquare3 = isoGridSquare0.nav[IsoDirections.N.index()];
                                        if (isoGridSquare3 == null || isoGridSquare3.getRoom() == null) {
                                            boolean5 = false;
                                        }
                                    }
                                } else {
                                    IsoGridSquare isoGridSquare4 = isoGridSquare0.nav[IsoDirections.W.index()];
                                    if (isoGridSquare4 == null || isoGridSquare4.getRoom() == null) {
                                        boolean5 = false;
                                    }
                                }
                            }

                            if (!boolean5) {
                                IsoGridSquare.CircleStencil = boolean1;
                            }

                            isoObject.setAlphaAndTarget(int2, 1.0F);
                        }

                        if (isoObject.sprite.getProperties().Is(IsoFlagType.cutW) && isoObject.sprite.getProperties().Is(IsoFlagType.cutN)) {
                            int5 = DoWallLightingNW(isoGridSquare0, isoObject, int5);
                        } else if (isoObject.sprite.getType() == IsoObjectType.doorFrW
                            || isoObject.sprite.getType() == IsoObjectType.doorW
                            || isoObject.sprite.getProperties().Is(IsoFlagType.cutW)) {
                            int5 = DoWallLightingW(isoGridSquare0, isoObject, int5);
                        } else if (isoObject.sprite.getType() == IsoObjectType.doorFrN
                            || isoObject.sprite.getType() == IsoObjectType.doorN
                            || isoObject.sprite.getProperties().Is(IsoFlagType.cutN)) {
                            int5 = DoWallLightingN(isoGridSquare0, isoObject, int5);
                        }
                    } else {
                        if (isoGridSquare1 != null) {
                        }

                        isoObject.setTargetAlpha(int2, 1.0F);
                        if (IsoCamera.CamCharacter != null
                            && isoObject.getProperties() != null
                            && (isoObject.getProperties().Is(IsoFlagType.solid) || isoObject.getProperties().Is(IsoFlagType.solidtrans))) {
                            int int7 = isoGridSquare0.getX() - (int)IsoCamera.CamCharacter.getX();
                            int int8 = isoGridSquare0.getY() - (int)IsoCamera.CamCharacter.getY();
                            if (int7 > 0 && int7 < 3 && int8 >= 0 && int8 < 3 || int8 > 0 && int8 < 3 && int7 >= 0 && int7 < 3) {
                                isoObject.setTargetAlpha(int2, 0.99F);
                            }
                        }

                        if (isoObject instanceof IsoWindow && isoObject.getTargetAlpha(int2) < 1.0E-4F) {
                            IsoWindow isoWindow = (IsoWindow)isoObject;
                            IsoGridSquare isoGridSquare5 = isoWindow.getOppositeSquare();
                            if (isoGridSquare5 != null && isoGridSquare5 != isoGridSquare0 && isoGridSquare5.lighting[int2].bSeen()) {
                                isoObject.setTargetAlpha(int2, isoGridSquare5.lighting[int2].darkMulti() * 2.0F);
                            }
                        }

                        if (isoObject instanceof IsoTree) {
                            if (boolean1
                                && isoGridSquare0.x >= (int)IsoCamera.frameState.CamCharacterX
                                && isoGridSquare0.y >= (int)IsoCamera.frameState.CamCharacterY
                                && isoGridSquare1 != null
                                && isoGridSquare1.Is(IsoFlagType.exterior)) {
                                ((IsoTree)isoObject).bRenderFlag = true;
                            } else {
                                ((IsoTree)isoObject).bRenderFlag = false;
                            }
                        }

                        isoObject.render((float)isoGridSquare0.x, (float)isoGridSquare0.y, (float)isoGridSquare0.z, defColorInfo, true, false, null);
                    }

                    if (isoObject.sprite != null) {
                        isoObject.renderObjectPicker((float)isoGridSquare0.x, (float)isoGridSquare0.y, (float)isoGridSquare0.z, defColorInfo);
                    }

                    if ((isoObject.highlightFlags & 2) != 0) {
                        isoObject.highlightFlags &= -2;
                    }
                }
            }
        }

        return boolean2;
    }

    private static void renderCharacters(IsoGridSquare isoGridSquare, boolean boolean0) {
        int int0 = isoGridSquare.getStaticMovingObjects().size();

        for (int int1 = 0; int1 < int0; int1++) {
            IsoMovingObject isoMovingObject0 = (IsoMovingObject)isoGridSquare.getStaticMovingObjects().get(int1);
            if (isoMovingObject0.sprite != null
                && (!boolean0 || isoMovingObject0 instanceof IsoDeadBody)
                && (boolean0 || !(isoMovingObject0 instanceof IsoDeadBody))) {
                isoMovingObject0.render(isoMovingObject0.getX(), isoMovingObject0.getY(), isoMovingObject0.getZ(), defColorInfo, true, false, null);
                isoMovingObject0.renderObjectPicker(isoMovingObject0.getX(), isoMovingObject0.getY(), isoMovingObject0.getZ(), defColorInfo);
            }
        }

        int0 = isoGridSquare.getMovingObjects().size();

        for (int int2 = 0; int2 < int0; int2++) {
            IsoMovingObject isoMovingObject1 = (IsoMovingObject)isoGridSquare.getMovingObjects().get(int2);
            if (isoMovingObject1 != null && isoMovingObject1.sprite != null) {
                boolean boolean1 = isoMovingObject1.isOnFloor();
                if (boolean1 && isoMovingObject1 instanceof IsoZombie isoZombie) {
                    boolean1 = isoZombie.bCrawling
                        || isoZombie.legsSprite.CurrentAnim != null
                            && isoZombie.legsSprite.CurrentAnim.name.equals("ZombieDeath")
                            && isoZombie.def.isFinished();
                }

                if ((!boolean0 || boolean1) && (boolean0 || !boolean1)) {
                    isoMovingObject1.setAlphaAndTarget(0, 1.0F);
                    if (isoMovingObject1 instanceof IsoGameCharacter isoGameCharacter) {
                        isoGameCharacter.renderServerGUI();
                    } else {
                        isoMovingObject1.render(isoMovingObject1.getX(), isoMovingObject1.getY(), isoMovingObject1.getZ(), defColorInfo, true, false, null);
                    }

                    isoMovingObject1.renderObjectPicker(isoMovingObject1.getX(), isoMovingObject1.getY(), isoMovingObject1.getZ(), defColorInfo);
                }
            }
        }
    }

    private static void renderUI() {
    }
}
